package com.sprucetec.live.util;

import com.sprucetec.live.base.entity.User;
import com.sprucetec.live.common.webcontext.LoginUserContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 
 * Title: SsoUtil<br>
 * Description: <br>
 * Copyright: Copyright (c) 2016<br>
 * Company: 北京云杉世界信息技术有限公司<br>
 * @author YAN 2017-3-1 11:24:40
 */
@Slf4j
@Component
public class SsoUtil {



    public static final User getLoginUser() {
        return LoginUserContext.getUser();
    }

    public static Long userId() throws Exception {
        try {
            return getLoginUser().getId();
        } catch (Exception e) {
            throw new Exception("SSO 获取用户信息失败", e);
        }
    }

    public static Set<String> getAccessUrls () {
    	
        User user = LoginUserContext.getUser();
        return user.getAccessList();
    }
}
